import time
from selenium import webdriver
from selenium.webdriver.common.by import By
# 作业1：
# url：http://www.bjhospital.net/
# 用例1：
# 搜索骨科—>点击搜索—>点击出来的第一个链接—>断言文本内容
driver = webdriver.Chrome()
driver.get("http://www.bjhospital.net/")
driver.maximize_window()
driver.implicitly_wait(15)

driver.find_element(By.CLASS_NAME,"keyword").send_keys("骨科")

driver.find_elements(By.CLASS_NAME,"btn")[0].click()

driver.find_element(By.XPATH,"/html/body/div[4]/ul/li[1]/div[1]/h5/a").click()

win = driver.window_handles
driver.switch_to.window(win[-1])
time.sleep(2)

text = driver.find_element(By.XPATH,"/html/body/div[3]/div/div/article/h1").text
print(f"通过text返回的文本：{text}")
assert text == "毕节市第一人民医院高值医用耗材网上阳光平台议价意向公开"

time.sleep(3)



